#include "dll_aip.h"
#include <iostream>
#include "Dev_Motor.h"

static Dev_Motor* motor_dev = nullptr;

int Motor_Init(const char* dev_name)
{
    if (motor_dev == nullptr) {
        motor_dev = new Dev_Motor();
        std::cout << "Motor" << dev_name << " initialized ok." << std::endl;
    }
    return 0;
}
int Motor_Run(const char* dev_name)
{
    if (motor_dev == nullptr) {
        std::cout << "Motor" << dev_name << " not initialized." << std::endl;
        return -1; // Error: Motor not initialized
    }
    motor_dev->run();
    return 0;
}
int Motor_Stop(const char* dev_name)
{
    if (motor_dev == nullptr) {
        std::cout << "Motor" << dev_name << " not initialized." << std::endl;
        return -1; // Error: Motor not initialized
    }
    motor_dev->close();
    return 0;
}
int Motor_DeInit(const char* dev_name)
{
    delete motor_dev;
    motor_dev = nullptr;
    std::cout << "Motor" << dev_name << " De-initialized ok." << std::endl;
    return 0;
}